import * as types from './../constants/ActionTypes';

/*
 * 充值配置参数
 ================================================================*/
export function fetchRechargeConfig({priceid, paymethod, randcode} = {}) {
    return (dispatch) => {
        let payload = {
            recharge_config_status: 0,
            message: '加载中'
        };
        dispatch({
            payload,
            type: [types.FETCH_RECHARGE_CONFIG, types.FETCH_RECHARGE_CONFIG_SUCCESS, types.FETCH_RECHARGE_CONFIG_FAILURE],
                meta: {
                    fetch: [`pay/app`, {
                        method: 'post',
                        body: `priceid=${priceid}&paymethod=${paymethod}&randcode=${randcode}`
                    }]
                }
        });
    };
}

export function checkRechargeStatus(randcode){
    return (dispatch) => {
        let payload = {
            recharge_result_status: 0,
            message: '加载中'
        };
        dispatch({
            payload,
            type: [types.FETCH_RECHARGE_STATUS, types.FETCH_RECHARGE_STATUS_SUCCESS, types.FETCH_RECHARGE_STATUS_FAILURE],
                meta: {
                    fetch: [`recharge/alipaystatus?randcode=${randcode}`, {
                        method: 'get'
                    }]
                }
        });
    };
}